package com.teamwork.shareplatform.service.impl;

import com.github.pagehelper.PageHelper;
import com.teamwork.shareplatform.entity.Files;
import com.teamwork.shareplatform.mapper.FilesMapper;
import com.teamwork.shareplatform.service.FilesService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

@Service
@Transactional
public class FilesServiceImpl implements FilesService {

    @Resource
    FilesMapper filesMapper;

    @Override
    public List<Files> queryByUid(int uid, int currentPage, int pageSize) {
        PageHelper.startPage(currentPage, pageSize);
        return filesMapper.queryByUid(uid);
    }

    @Override
    public List<Files> queryAllFiles(int currentPage, int pageSize) {
        PageHelper.startPage(currentPage, pageSize);
        return filesMapper.queryAllFiles();
    }

    @Override
    public List<Files> queryByCid(int sid, int currentPage, int pageSize) {
        PageHelper.startPage(currentPage, pageSize);
        return filesMapper.queryByCid(sid);
    }

    @Override
    public String queryFilePath(int fid) {
        return filesMapper.queryFilePath(fid);
    }

    @Override
    public int deleteFiles(int id) {
        return filesMapper.deleteFiles(id);
    }

    @Override
    public int addFiles(Files files) {
        return filesMapper.addFiles(files);
    }
}